package day20171202.test01;

import java.sql.*;

public class Test {
    public static void main(String[] args) {

        Connection connection=null;
        Statement statement=null;
        ResultSet resultSet=null;

        String sql="insert into" +
                "t_students(id,stu_no,real_name,age,gender,department)"
                +"values(1,'1001','张三',18,'女','信息与工程学院')";

        try {
            Class.forName("com.mysql.jdbc.Driver");
            connection= DriverManager.getConnection(
                    "jdbc:mysql://localhost:3306/java_2017?serverTimezone=UTC",
                    "root",
                    "444455"
            );

            statement =connection.createStatement();

            statement.execute(sql);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            try {
                statement.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }
}
